<template>
  <el-table
    height="100%"
    border
    :data="schoolgroup.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
    style="width: 100%"
  >
    <el-table-column label="序号" prop="ID" width="180"></el-table-column>
    <el-table-column label="题库组名称" prop="name"></el-table-column>

    <el-table-column label="操作" width="280">
      <template slot-scope="scope">
        <el-button size="middle" type="primary" @click="handleLook(scope.$index, scope.row)">查看</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  name: "group",
  data() {
    return {
      search: "",
      schoolgroup: [],
      groupdetail: []
    };
  },
  methods: {
    handleLook(index, row) {
      console.log(index, row);
      this.isShow = !this.isShow;

      this.$axios({
        method: "post",
        url: "/v4/backAdmin/getschoolitembank",
        xsrfCookieName: "csrfToken", // default
        xsrfHeaderName: "x-csrf-token", // 默认的
        data: {
          schoolitembankgroupid: row.ID
        }
      })
        .then(data => {
          // console.log(data.data.data)
          this.groupdetail = data.data.data;
          this.$router.push({
            path: "/school/school_groupdetail/" + this.$route.params.ID,
            query: { detail: this.groupdetail }
          });
        })
        .catch(err => {
          console.log(err);
        });
    }
  },
  created() {
    this.$axios({
      method: "post",
      url: "/v4/backAdmin/getschoolitembankgroup",
      xsrfCookieName: "csrfToken", // default
      xsrfHeaderName: "x-csrf-token", // 默认的
      data: {
        schoolid: this.$route.params.ID
      }
    })
      .then(data => {
        this.schoolgroup = data.data.data;
      })
      .catch(err => {
        console.log(err);
      });
  }
};
</script>
